package com.aidex.system.controller;

import java.util.List;
import com.aidex.common.annotation.Log;
import com.aidex.common.core.domain.R;
import com.github.pagehelper.PageInfo;
import com.aidex.common.core.page.PageDomain;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.aidex.common.enums.BusinessType;
import com.aidex.common.utils.poi.ExcelUtil;
import javax.validation.constraints.*;
import org.springframework.web.bind.annotation.*;
import com.aidex.common.core.controller.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import com.aidex.system.domain.RunLog;
import com.aidex.system.service.RunLogService;

/**
 * 运单接收日志Controller
 * @author jmy
 * @email jmyinjg@163.com
 * @date 2021-11-09
 */
@RestController
@RequestMapping("/system/runLog")
public class RunLogController extends BaseController
{
    @Autowired
    private RunLogService runLogService;

    /**
     * 查询运单接收日志列表
     */
//    @PreAuthorize("@ss.hasPermi('system:runLog:list')")
    @GetMapping("/list")
    public R<PageInfo> list(RunLog runLog, HttpServletRequest request, HttpServletResponse response)
    {
        runLog.setPage(new PageDomain(request, response));
        return R.data(runLogService.findPage(runLog));
    }

    /**
     * 获取运单接收日志详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:runLog:query')")
    @GetMapping(value = "/{id}")
    public R<RunLog> detail(@PathVariable("id") String id)
    {
        return R.data(runLogService.get(id));
    }

    /**
     * 新增运单接收日志
     */
//    @PreAuthorize("@ss.hasPermi('system:runLog:add')")
    @Log(title = "运单接收日志", businessType = BusinessType.INSERT)
    @PostMapping
    public R add(@RequestBody @Validated  RunLog runLog)
    {
        return R.status(runLogService.save(runLog));
    }

    /**
     * 修改运单接收日志
     */
//    @PreAuthorize("@ss.hasPermi('system:runLog:edit')")
    @Log(title = "运单接收日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public R edit(@RequestBody @Validated RunLog runLog)
    {
        return R.status(runLogService.save(runLog));
    }


    /**
     * 删除运单接收日志
     */
//    @PreAuthorize("@ss.hasPermi('system:runLog:remove')")
    @Log(title = "运单接收日志", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R remove(@PathVariable String[] ids)
    {
        return R.status(runLogService.deleteRunLogByIds(ids));
    }


    /**
     * 导出运单接收日志列表
     */
//    @PreAuthorize("@ss.hasPermi('system:runLog:export')")
    @Log(title = "运单接收日志", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public R export(RunLog runLog)
    {
        List<RunLog> list = runLogService.findList(runLog);
        ExcelUtil<RunLog> util = new ExcelUtil<RunLog>(RunLog.class);
        return util.exportExcel(list, "runLog");
    }

}
